from dateutil.parser import isoparse
from datetime import timezone, timedelta


def iso_to_times(iso_time):
    if iso_time is None or not iso_time:
        time_second = 0
    else:
        timestamp = isoparse(iso_time).timestamp()
        time_second = int(timestamp)
    return time_second


def datetime_to_times(datetime_time):
    if datetime_time is None or not datetime_time:
        time_second = 0
    else:
        # dt_east8 = datetime_time.astimezone(timezone(timedelta(hours=8)))
        # time_second = int(dt_east8.timestamp())
        time_second = int(datetime_time.timestamp())
    return time_second

